package map;

import java.util.HashMap;

public class BullsAndCows299 {

    public String getHint(String secret, String guess) {
        if (secret == null || guess == null) {
            return "";
        }
        int count_a = 0;
        int[] s_index = new int[10];
        int[] g_index = new int[10];
        for (int i = 0; i < secret.length(); i++) {
            char s = secret.charAt(i);
            char g = guess.charAt(i);
            if (s == g) {
                count_a++;
            }
            g_index[g - '0']++;
            s_index[s - '0']++;
        }

        int count_b = 0;
        for (int i = 0; i < 10; i++) {
            count_b += Math.min(s_index[i] , g_index[i]);
        }
        count_b = count_b - count_a;
        return "" + count_a + 'A' + count_b + 'B';
    }
}
